package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Test4 {
    public static void main(String[] args) throws IOException {
        File file = new File("./src/main/java/io");
        FileFilter filter = new FileFilter() {
            @Override
            public boolean accept(File file) {
                String name = file.getName();
                System.out.println("正在过滤的项目是："+name);
                return name.endsWith(".java");
            }
        };
        File[] subs = file.listFiles(filter);

        for (int i = 0; i < subs.length; i++) {
            FileInputStream fis = new FileInputStream(subs[i]);
            fis = new FileInputStream(subs[i]);
            long len = subs[i].length();
            byte[] data = new byte[(int) len];
            fis.read(data);
            String line = new String(data, StandardCharsets.UTF_8);
            System.out.println(line);
            fis.close();
        }

    }
}
